/**
 * p:main
 */
function createProHtml(p,i){
	 var html='';
     var hangClass='ul-header bg-white';
     if(i%2!=0){
       hangClass='ul-header bg-second';
     }     
     	var type="";
     	 var code =p.CODE;
         if(code==""||code ==null){
         	code="-";
         }
     	//编号
		var ggid=p.GWWID;
		if(ggid==""||ggid==null){
			ggid="-";
		}
		
		//管线名称
		var lineName=p.LINENAME;
		if(""==lineName||null==lineName){
			lineName="-";
		}
		//管段名称
		var segmentName=p.SEGMENTNAME;
		if(""==segmentName||null==segmentName){
			segmentName="-";
		}
		
		//环焊缝编号
		var gwwNum=p.GWWNUM;
		
		if(""==gwwNum||null==gwwNum){
			gwwNum="-";
		}
		//检修或施工单位
		var company=p.COMPANY;
		if(""==company||null==company){
			company="-"
		}
		
		var mileage=p.MILEAGE
		if(""==mileage||null==mileage){
			mileage="-"
		}
		
		//来源
		var source=p.SOURCE;
		
		
		//GISID
		var gisId=p.GIS_ID;
		if(""==gisId||null==gisId){
			gisId="";
		}
		
		
    var tableName;
     
 	if(source=='0'){
 		tableName="gww";
		hhtml='<div class=\"show-ul none\">'
			+' <ul class=\"show-list\">'
			+'<li> <span class=\"s1\">统一编号:</span><span class=\"s2\">'+code+'</span></li>'
			+'<li> <span class=\"s1\">管线名称:</span><span class=\"s2\">'+lineName+'</span></li>'
			+'<li> <span class=\"s1\">管段名称:</span> <span class=\"s2\">'+segmentName+'</span></li>'
			+'<li> <span class=\"s1\">环焊缝焊接编号:</span> <span class=\"s2\">'+gwwNum+'</span></li>'
			+'<li> <span class=\"s1\">绝对距离(m):</span> <span class=\"s2\">-</span></li>'
			+'<li> <span class=\"s1\">WPS编号:</span> <span class=\"s2\">-</span></li>'
			+'<li> <span class=\"s1\">施工单位:</span> <span class=\"s2\">'+company+'</span></li>'
			+'<li> <span class=\"s1\">施工日期:</span> <span class=\"s2\">-</span></li>'
			+'<li> <span class=\"s1\">记录人:</span> <span class=\"s2\">-</span></li>'
			+'<li> <span class=\"s1\">记录时间:</span> <span class=\"s2\">-</span></li>'
			+'<li class=\"last-li\"><span class=\"s1\">备注:</span><span class=\"s2\"><textarea readonly="readonly" disabled="disabled"placeholder=\"备注描述\">-</textarea></span></li>'
			+'</ul></div></div><input type="hidden" name="gisHiddenName" value=' + gisId +'>';
	}else if(source=='1'){
		hhtml='<div class=\"show-ul none\">'
			+' <ul class=\"show-list\">'
			+'<li> <span class=\"s1\">统一编号:</span><span class=\"s2\">'+code+'</span></li>'
			+'<li> <span class=\"s1\">管线名称:</span><span class=\"s2\">-</span></li>'
			+'<li> <span class=\"s1\">管段名称:</span> <span class=\"s2\">-</span></li>'
			+'<li> <span class=\"s1\">环焊缝焊接编号:</span> <span class=\"s2\">-</span></li>'
			+'<li> <span class=\"s1\">无损检测类型:</span> <span class=\"s2\">-</span></li>'
			+'<li> <span class=\"s1\">是否返修:</span> <span class=\"s2\">-</span></li>'
			+'<li> <span class=\"s1\">检测单位:</span> <span class=\"s2\">-</span></li>'
			+'<li> <span class=\"s1\">检测日期:</span> <span class=\"s2\">-</span></li>'
			+'<li> <span class=\"s1\">检测报告:</span> <span class=\"s2\">-</span></li>'
			+'<li> <span class=\"s1\">记录人:</span> <span class=\"s2\">-</span></li>'
			+'<li> <span class=\"s1\">记录时间:</span> <span class=\"s2\">-</span></li>'
			+'<li class=\"last-li\"><span class=\"s1\">备注:</span><span class=\"s2\"><textarea readonly="readonly" disabled="disabled"  placeholder=\"备注描述\">-</textarea></span></li>'
			+'</ul></div></div>'
	}else{
		hhtml="";
	}
	
	

	
	html+='<div class=\"info-tr\"><ul class=\"ul-header '
		+ hangClass
		+ '\"><li class=\"w20\">'
		+ lineName
		+ '</li><li class=\"w20\">'
		+ segmentName
		+ '</li><li class=\"w20\">'
		+ gwwNum
		+ '</li><li class=\"w10\">'
		+ mileage
		+ '</li><li class="w20">'
		+ company
		+ '</li><li class=\"w10 no-right\"><em class=\"xq-icon\" id="'+ggid+','+source+'"></em></li></ul>'
		+hhtml;
	return html;
	
}


function getGWWClick(){

    var pagePath = $("#pagePath").val();

    var lineId = $("#lineDiv").children().attr("id");
    var segmentId = $("#segmentDiv").children().attr("id");
    var startMileage = $("#startMileage").val();
    var endMileage = $("#endMileage").val();
    if(lineId == "lineAll" || lineId == "" || lineId == undefined){
        lineId = "";
    }
    if(segmentId == "segmentAll" || segmentId == "" || segmentId == undefined){
        segmentId = "";
    }
    if (startMileage == null || startMileage == "") {
        startMileage = 0;
    }
    if (endMileage == null || endMileage == "") {
        endMileage = 0;
    }
	
	//给隐藏表单域赋值
	$("#lineHiddenId").val(lineId);
	$("#segmentHiddenId").val(segmentId);
	$("#startMileHiddenId").val(startMileage);
	$("#endMileHiddenId").val(endMileage);

    var data = {"pipeLineId":lineId,"pipeSegmentId":segmentId, "startMileage":startMileage, "endMileage":endMileage};

	var b = window.sessionStorage;
	b.removeItem("mapData");
	b.setItem("mapData", JSON.stringify(data));

	var map={"fillDiv":"#searchBody", "url":""+pagePath+"/basedata/pipeGwwController/getBase.json"};

	searchPage(map,data);
}


function gwwDonload(){
    var pagePath = $("#pagePath").val();

    var lineId = $("#lineDiv").children().attr("id");
    var segmentId = $("#segmentDiv").children().attr("id");
    var startMileage = $("#startMileage").val();
    var endMileage = $("#endMileage").val();
    if(lineId == "lineAll" || lineId == "" || lineId == undefined){
        lineId = "";
    }
    if(segmentId == "segmentAll" || segmentId == "" || segmentId == undefined){
        segmentId = "";
    }
    if (startMileage == null || startMileage == "") {
        startMileage = 0;
    }
    if (endMileage == null || endMileage == "") {
        endMileage = 0;
    }
	
	 $("input[name='pipeLineId']").val(lineId);
     $("input[name='pipeSegmentId']").val(segmentId);
     $("input[name='startMileage']").val(startMileage);
     $("input[name='endMileage']").val(endMileage);
	
	$("#gwwForm").attr("action", pagePath + "/basedata/pipeGwwController/getExcel.html");
	$("#gwwForm").submit();
}

/**
 * 日期格式化
 * @param format
 * @returns
 */
Date.prototype.Format = function(format){ 
	var o = { 
	"M+" : this.getMonth()+1, //month 
	"d+" : this.getDate(), //day 
	"h+" : this.getHours(), //hour 
	"m+" : this.getMinutes(), //minute 
	"s+" : this.getSeconds(), //second 
	"q+" : Math.floor((this.getMonth()+3)/3), //quarter 
	"S" : this.getMilliseconds() //millisecond 
	} 

	if(/(y+)/.test(format)) { 
	format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length)); 
	} 

	for(var k in o) { 
	if(new RegExp("("+ k +")").test(format)) { 
	format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length)); 
	} 
	} 
	return format; 
	} 
/**
 * 查询详情
 * @param t:$(this)  当前对象
 * @param ggwIdSource：包含gwwId和source
 */
function gwwDetails(t,gwwIdSource){
	var strs=new Array();
	strs=gwwIdSource.split(",");
	
	var gwwId=strs[0];
	var type=strs[1];

    var pagePath = $("#pagePath").val();
	var url= pagePath+"/basedata/pipeGwwController/getDetails.json";
	
	
	$.ajax({
		type:"post",
		url:url,
		data:{gwwID:gwwId,type:type},
		dataType:"json",
		success:function(data){
			
			if(null!=data&&""!=data){
				var code = data.result.code;
			
				
				//判断状态码是否为正确
				if(code==0000000000){
					var obj=data.result.obj;
					if(null!=obj&&""!=obj){
							if(type=='0'){
								//如果状态为0，则说明注入的是环焊缝详情
								
								var code =obj.CODE;
						         if(code==""||code ==null){
						         	code="-";
						         }
						         t.parents('.ul-header').next().find('.show-list li').eq(0).find('span').eq(1).html(code);
								//管线名称
								var LINENAME=obj.lineName;
								if(null==LINENAME||""==LINENAME){
									LINENAME="-";
								}
								
								t.parents('.ul-header').next().find('.show-list li').eq(1).find('span').eq(1).html(LINENAME);
								
								//管段名称
								var SEGMENTNAME=obj.segmentName;
								if(null==SEGMENTNAME||""==SEGMENTNAME){
									SEGMENTNAME="-";
								}
								t.parents('.ul-header').next().find('.show-list li').eq(2).find('span').eq(1).html(SEGMENTNAME);
								
								//环焊缝焊接编号
								var GWW_NUMBER=obj.GWW_NUMBER;
								if(null==GWW_NUMBER||""==GWW_NUMBER){
									GWW_NUMBER="-";
								}
								t.parents('.ul-header').next().find('.show-list li').eq(3).find('span').eq(1).html(GWW_NUMBER);
								
								
								//绝对距离
								var MILEAGE=""+obj.MILEAGE;
								if(null==MILEAGE||""==MILEAGE||"undefined"==MILEAGE){
									MILEAGE="-";
								}
								
								t.parents('.ul-header').next().find('.show-list li').eq(4).find('span').eq(1).html(MILEAGE);
								
								
								//WPS编号
								var WPS_NUMBER=obj.WPS_NUMBER;
								if(null==WPS_NUMBER||""==WPS_NUMBER){
									WPS_NUMBER="-";
								}
								
								t.parents('.ul-header').next().find('.show-list li').eq(5).find('span').eq(1).html(WPS_NUMBER);
							
								//施工单位
								var ASSEMBLY_COMPANY=obj.ASSEMBLY_COMPANY;
								if(null==ASSEMBLY_COMPANY||""==ASSEMBLY_COMPANY){
									ASSEMBLY_COMPANY="-";
								}
								t.parents('.ul-header').next().find('.show-list li').eq(6).find('span').eq(1).html(ASSEMBLY_COMPANY);
								
								//施工日期
								var CONSTRUCTION_DATE= obj.CONSTRUCTION_DATE;
									
								
								
								
								if(null==CONSTRUCTION_DATE||""==CONSTRUCTION_DATE){
									CONSTRUCTION_DATE="-";
								}else{
									CONSTRUCTION_DATE= new Date(obj.CONSTRUCTION_DATE).Format("yyyy-MM-dd");
									
								}
								
								
								
								t.parents('.ul-header').next().find('.show-list li').eq(7).find('span').eq(1).html(CONSTRUCTION_DATE);
							
								
								//记录人
								var RECORDER=obj.RECORDER;
								if(null==RECORDER||""==RECORDER){
									RECORDER="-";
									
								}
								t.parents('.ul-header').next().find('.show-list li').eq(8).find('span').eq(1).html(RECORDER);
								
								//记录时间
								var RECORDTIME=obj.RECORDTIME;
								
								if(null==RECORDTIME||""==RECORDTIME){
									RECORDTIME="-";
								}else{
									RECORDTIME=new Date(obj.RECORDTIME).Format("yyyy-MM-dd");
								}
								t.parents('.ul-header').next().find('.show-list li').eq(9).find('span').eq(1).html(RECORDTIME);
								
								
								//备注
								var CREATE_REMARK=obj.CREATE_REMARK;
								if(null==CREATE_REMARK||""==CREATE_REMARK){
									CREATE_REMARK="-";
								}
								t.parents('.ul-header').next().find('.show-list li').eq(10).find('span').eq(1).find("textarea").html(CREATE_REMARK);
								
								initTitle();
							}else if(type=="1"){
								//如果状态为1，则说明注入的数据是环焊缝无损信息
								var code =obj.CODE;
						         if(code==""||code ==null){
						         	code="-";
						         }
						         t.parents('.ul-header').next().find('.show-list li').eq(0).find('span').eq(1).html(code);
								
								//管线名称
								var LINENAME=obj.LINENAME;
								if(null==LINENAME||""==LINENAME){
									LINENAME="-";
								}
								t.parents('.ul-header').next().find('.show-list li').eq(0).find('span').eq(2).html(LINENAME);
								
								
								//管段名称
								var SEGMENTNAME=obj.SEGMENTNAME;
								if(null==SEGMENTNAME||""==SEGMENTNAME){
									SEGMENTNAME="-";
								}
								t.parents('.ul-header').next().find('.show-list li').eq(0).find('span').eq(3).html(SEGMENTNAME);
								
								//环焊缝焊接编号
								var GWW_NUMBER=obj.GWW_NUMBER;
								if(null==GWW_NUMBER||""==GWW_NUMBER){
									GWW_NUMBER="-";
								}
								t.parents('.ul-header').next().find('.show-list li').eq(0).find('span').eq(4).html(GWW_NUMBER);
								
								//无损检测类型
								var NDT_TYPE=obj.NDT_TYPE;
								if(null==NDT_TYPE||""==NDT_TYPE){
									NDT_TYPE="-";
								}
								t.parents('.ul-header').next().find('.show-list li').eq(0).find('span').eq(5).html(NDT_TYPE);
								
								//是否返修
								var REPAIRIND=obj.REPAIRIND;
								if(null==REPAIRIND||""==REPAIRIND){
									REPAIRIND="-";
								}
								t.parents('.ul-header').next().find('.show-list li').eq(0).find('span').eq(6).html(REPAIRIND);
								
								//检测单位
								var TESTING_COMPANY=obj.TESTING_COMPANY;
								if(null==TESTING_COMPANY||""==TESTING_COMPANY){
									TESTING_COMPANY="-";
								}
								
								t.parents('.ul-header').next().find('.show-list li').eq(0).find('span').eq(7).html(TESTING_COMPANY);
								
								//检测日期
								var TEST_DATE=obj.TEST_DATE;
							
								
								if(null==TEST_DATE||""==TEST_DATE){
									TEST_DATE="-";
								}else{
									TEST_DATE=new Date(obj.TEST_DATE).Format("yyyy-MM-dd");
								}
								t.parents('.ul-header').next().find('.show-list li').eq(0).find('span').eq(8).html(TEST_DATE);
								
								//检测报告
								var TESTING_REPORT=obj.TESTING_REPORT;
								if(null==TESTING_REPORT||""==TESTING_REPORT){
									TESTING_REPORT="-";
								}
								t.parents('.ul-header').next().find('.show-list li').eq(0).find('span').eq(9).html(TESTING_REPORT);
								
								//记录人
								var RECORDER=obj.RECORDER;
								if(null==RECORDER||""==RECORDER){
									RECORDER="-";
								}
								t.parents('.ul-header').next().find('.show-list li').eq(0).find('span').eq(10).html(RECORDER);
								
								//记录时间
								var RECORD_TIME=obj.RECORD_TIME;

								
								if(null==RECORD_TIME||""==RECORD_TIME){
									RECORD_TIME="-";
								}else{
									 RECORD_TIME=new Date(obj.RECORD_TIME).Format("yyyy-MM-dd")
								}
								t.parents('.ul-header').next().find('.show-list li').eq(0).find('span').eq(11).html(RECORD_TIME);
							
								//备注
								var CREATE_REMARK=obj.CREATE_REMARK;
								if(null==CREATE_REMARK||""==CREATE_REMARK){
									CREATE_REMARK="-";
								}
								
								t.parents('.ul-header').next().find('.show-list li').eq(0).find('span').eq(12).find("textarea").html(CREATE_REMARK);
								initTitle();
							}
					}

				}
			}

		}

	});
}




